package com.gyt.manage.cms.controller;

import com.gyt.framework.domain.cms.CmsPage;
import com.gyt.framework.exception.BaseException;
import com.gyt.framework.response.Response;
import com.gyt.framework.web.BaseController;
import com.gyt.manage.cms.service.CmsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author created by v_yantgao
 * @Date 2021/1/11 11:05
 */
@RestController
@RequestMapping("resource")
@Api(tags = "manage-cms",description = "资源中心-课程管理")
public class CmsController extends BaseController {

    @Autowired
    private CmsService cmsService;

    @ResponseBody
    @GetMapping("cms/findByPageName.do")
    @ApiOperation(value = "根据函数id批量删除函数", notes = "函数库")
    public Response<?> findByPageName(
            @ApiParam(value = "页面名称",required = true) @RequestParam(value = "pageName") String pageName){
        try {
            CmsPage cmsPage = cmsService.findByPageName(pageName);
            return Response.ok(cmsPage);
        } catch (BaseException e) {
            logger.error("findByPageName BaseException",e);
            return Response.error(e,null);
        } catch (Exception e) {
            logger.error("findByPageName Exception",e);
            return Response.error(e,null);
        }
    }

}
